#include "PostfixExpr.h"

#include <iostream>
#include <string>
#include <assert.h>
#include "../../symtab/symtab.h"
#include "PrimaryExpr.h"
#include "Expression.h"
#include "ArgumentExprList.h"
#include "../Declarations/InitializerList.h"
#include "../Declarations/TypeName.h"

PostfixExpr::~PostfixExpr(void)
{
	switch(m_iType)
	{
	case primary_expression:
		delete m_pPrimaryExpr;
		break;
	case arry_expression:
		delete m_pPostfixExpr;
		delete m_pArryExpr;
		break;
	case function_call_with_argument:
		delete m_pArguments;
	case function_call_no_argument:
	case point_expression:
	case arrow_expression:
	case plus_expression:
	case sub_expression:
		delete m_pPostfixExpr;
		break;
	case type_initial_expression:
		delete m_pInitializer;
		delete m_pIdentifier;
		break;
	default:
		std::cout<<"PostfixExpr::~PostfixExpr(): unknown type"<<std::endl;
		exit(1);
	}

}

void PostfixExpr::codeGen()
{
	COUT
	switch(m_iType)
	{
	case primary_expression:
		m_pPrimaryExpr->codeGen();
		break;
	case arry_expression:
		m_pPostfixExpr->codeGen();
		m_pArryExpr->codeGen();
		break;
	case function_call_with_argument:
		m_pArguments->codeGen();
	case function_call_no_argument:
	case point_expression:
	case arrow_expression:
	case plus_expression:
	case sub_expression:
		m_pPostfixExpr->codeGen();
		break;
	case type_initial_expression:
		m_pInitializer->codeGen();
		break;
	default:
		std::cout<<"PostfixExpr::codeGen(): unknown type"<<std::endl;
		exit(1);
	}
}